package com.kili.cloud.common.errorpage;

import org.springframework.boot.web.server.ErrorPage;
import org.springframework.boot.web.server.ErrorPageRegistrar;
import org.springframework.boot.web.server.ErrorPageRegistry;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Component;

/**
 * @description: 异常返回配置处理类
 * @author: tom.liu
 * @date: 2019/6/14 10:35
 */
@Component
public class ErrorConfig implements ErrorPageRegistrar {

    @Override
    public void registerErrorPages(ErrorPageRegistry registry) {
        ErrorPage error400Page = new ErrorPage(HttpStatus.BAD_REQUEST, "/error_400.html");
        ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/error_401.html");
        ErrorPage error403Page = new ErrorPage(HttpStatus.FORBIDDEN, "/error_403.html");
        ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/error_404.html");
        ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/error_500.html");
        registry.addErrorPages(error400Page,error401Page,error403Page,error404Page,error500Page);
    }
}
